package num94;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : DuJiabao
 * @Project : sword-finger-offer
 * @Time : 2021/5/9 0:25
 * @Desc : 中序遍历
 */
public class Solution {
  private List<Integer> res = new ArrayList<>();

  public List<Integer> inorderTraversal(TreeNode root) {
    recursion(root);
    return this.res;
  }

  public void recursion(TreeNode root) {
    if (root == null) return;
    inorderTraversal(root.left);
    this.res.add(root.val);
    inorderTraversal(root.right);
  }

  public static void main(String[] args) {
    TreeNode root = new TreeNode(1);
    root.right = new TreeNode(2);
    root.right.left = new TreeNode(3);
    List<Integer> res = new Solution().inorderTraversal(root);
    System.out.println(res);
  }

}
